//
//  PersonInfoButtonCell.m
//  carcareIOS
//
//  Created by wr on 15/11/13.
//  Copyright © 2015年 baozun. All rights reserved.
//

#import "PersonInfoButtonCell.h"
#define CELL_HEIGHT (70)
@interface PersonInfoButtonCell()

@property (nonatomic , strong) UIView * rightCornerView;

@property (nonatomic , strong) UILabel * rightTitleLabel;

@end

@implementation PersonInfoButtonCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier withTitleAndImageArr:(NSArray *)titleAndImageArr
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat leftImageVX = 47.5 * __MAIN_RATIO_375;
        CGFloat leftImageVY = 22;
        UIImage * leftImage = ImageNamed(titleAndImageArr[0][1]);
        
        [Factory imageViewWithFrame:CGRectMake(leftImageVX, leftImageVY, leftImage.size.width * __MAIN_RATIO_375, leftImage.size.height * __MAIN_RATIO_375) image:leftImage onView:self];
        
        CGFloat leftTitleLabelX = leftImageVX  + leftImage.size.width * __MAIN_RATIO_375 + 12 * __MAIN_RATIO_375;
        CGFloat leftTitleLabelW = __MAIN_WIDTH / 2 - leftTitleLabelX - 10 * __MAIN_RATIO_375;
        CGFloat leftTitleLabelY = 0;
        CGFloat leftTitleLabelH = CELL_HEIGHT;
        [Factory labelWithFrame:CGRectMake(leftTitleLabelX, leftTitleLabelY, leftTitleLabelW, leftTitleLabelH) font:FONT_DEFAULT_Light(14) text:titleAndImageArr[0][0] textColor:[Theme wordColor] onView:self textAlignment:NSTextAlignmentLeft];
        
        CGFloat rightImageVX = 57 * __MAIN_RATIO_375 + __MAIN_WIDTH / 2;
        CGFloat cornerW = 9;
        self.rightCornerView = [[[UIView viewWithFrame:CGRectMake(rightImageVX, (CELL_HEIGHT - cornerW ) / 2 , cornerW, cornerW)] resetBackgroundColor:[UIColor clearColor]] setupOnView:self];
        self.rightCornerView.layer.cornerRadius = cornerW / 2;
        self.rightCornerView.layer.masksToBounds = YES;
        
        CGFloat rightTitleLabelX = rightImageVX + cornerW + 12 * __MAIN_RATIO_375;
        //设备状态
        self.rightTitleLabel = [Factory labelWithFrame:CGRectMake(rightTitleLabelX, leftTitleLabelY, leftTitleLabelW, leftTitleLabelH) font:FONT_DEFAULT_Light(14) text:@"" textColor:[Theme wordColor] onView:self textAlignment:NSTextAlignmentLeft];

        self.leftButton = [[UIButton buttonWithFrame:CGRectMake(0, 0, __MAIN_WIDTH / 2, CELL_HEIGHT) title:@"" textColor:[UIColor clearColor] font:FONT_BUTTON click:nil] setupOnView:self];

        [self.leftButton setBackgroundImage:[ImageHelper imageWithSolidColor:[[UIColor blackColor] colorWithAlphaComponent:0.1] size:CGSizeMake(5, 5)] forState:UIControlStateHighlighted];
        self.rightButton = [[UIButton buttonWithFrame:CGRectMake(__MAIN_WIDTH / 2, 0, __MAIN_WIDTH / 2, CELL_HEIGHT) title:@"" textColor:[UIColor clearColor] font:FONT_BUTTON click:nil] setupOnView:self];
        
        [self.rightButton setBackgroundImage:[ImageHelper imageWithSolidColor:[[UIColor blackColor] colorWithAlphaComponent:0.1] size:CGSizeMake(5, 5)] forState:UIControlStateHighlighted];
        
        [[[UIView viewWithFrame:CGRectMake(__MAIN_WIDTH / 2 - 0.25, 0, (__MAIN_WIDTH == 320 ? 1 : 0.5), CELL_HEIGHT)] resetBackgroundColor:[Theme lineColor]] setupOnView:self];
        [[[UIView viewWithFrame:CGRectMake(0, CELL_HEIGHT - 0.5, __MAIN_WIDTH, 0.5)] resetBackgroundColor:[Theme lineColor]] setupOnView:self];
    }
    return self;
}
- (void)configWithCornerColor:(UIColor *)cornerColor withRightLabelText:(NSString *)text
{
    self.rightCornerView.backgroundColor = cornerColor;
    self.rightTitleLabel.text = text;
}
+ (CGFloat)getCellHeight
{
    return CELL_HEIGHT;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
